package handler

import (
	"strconv"
	"video-hub/model"

	"github.com/gin-gonic/gin"
)

func RepoAdd(c *gin.Context) {

	repoNo := c.PostForm("repoNo")
	repoName := c.PostForm("repoName")

	data := model.Repo{
		RepoNo:   repoNo,
		RepoName: repoName,
	}
	model.DB.Create(&data)

	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "success",
	})
	return

}

func OrderAdd(c *gin.Context) {

	orderNo := c.PostForm("orderNo")
	orderPrice, _ := strconv.Atoi(c.PostForm("orderPrice"))
	pid, _ := strconv.Atoi(c.PostForm("pid"))

	data := model.Order{
		OrderNo:    orderNo,
		OrderPrice: orderPrice,
		Pid:        pid,
	}
	model.DB.Create(&data)

	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "success",
	})
	return
}
